package com.balakitbbs.controller;

import org.springframework.beans.factory.annotation.Autowired; 
import java.util.*;               
import org.springframework.stereotype.Controller;               
import org.springframework.web.bind.annotation.PathVariable;               
import org.springframework.web.bind.annotation.RequestMapping;               
import org.springframework.web.servlet.ModelAndView;               
import com.balakitbbs.page.Page;               
import com.balakitbbs.page.SearchPageUtil;               
import com.balakitbbs.service.Bala_mainpost_tagService;
import com.balakitbbs.entity.Bala_mainpost_tag;
   /**
    * bala_mainpost_tag Controller类
    */ 
@Controller
public class Bala_mainpost_tagController{
	@Autowired
	private Bala_mainpost_tagService bala_mainpost_tagservice;

//增加主贴标签关系表
@RequestMapping("/page/{pageIndex}/{pageSize}/addBala_mainpost_tag")
public String addBala_mainpost_tag(Bala_mainpost_tag bala_mainpost_tag,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_mainpost_tag.setCdate(new Date());
	bala_mainpost_tag.setId(UUID.randomUUID().toString());
	bala_mainpost_tagservice.addBala_mainpost_tag(bala_mainpost_tag);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_mainpost_tag.do";
}


//删除主贴标签关系表
@RequestMapping("/page/{Id}/{pageIndex}/{pageSize}/delBala_mainpost_tag")
public String delBala_mainpost_tag(@PathVariable String Id,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_mainpost_tagservice.delBala_mainpost_tag(Id);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_mainpost_tag.do";
}


//修改主贴标签关系表
@RequestMapping("/page/{pageIndex}/{pageSize}/updateBala_mainpost_tag")
public String updateBala_mainpost_tag(Bala_mainpost_tag bala_mainpost_tag,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_mainpost_tag.setUdate(new Date());
	bala_mainpost_tagservice.updateBala_mainpost_tag(bala_mainpost_tag);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_mainpost_tag.do";
}


//查询主贴标签关系表
@RequestMapping("/page/{pageIndex}/{pageSize}/selectBala_mainpost_tag")
public ModelAndView selectBala_mainpost_tags(Bala_mainpost_tag bala_mainpost_tag,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	ModelAndView modelAndView = new ModelAndView();
	int selectBala_mainpost_tagCount = bala_mainpost_tagservice.selectBala_mainpost_tagsByPOJOCount(bala_mainpost_tag);
	Page page = new Page(pageIndex, pageSize, selectBala_mainpost_tagCount);
	SearchPageUtil spu = new SearchPageUtil();
	spu.setPage(page);
	modelAndView.addObject("data", bala_mainpost_tagservice.selectBala_mainpost_tagsByPojoPage(spu, bala_mainpost_tag));
	modelAndView.addObject("page", page);
	modelAndView.addObject("s", 1);
	modelAndView.addObject("po", new Bala_mainpost_tag());
	modelAndView.setViewName("/WEB-INF/page/bala_mainpost_tag.jsp");
	return modelAndView;
}

}

